﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;


namespace OF.Web.admin.controls
{
    /// <summary>
    /// Handler 的摘要说明
    /// </summary>
    public class service : IHttpHandler, IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            isNewOrder(context);
        }

        #region 判断是否有未处理订单
        /// <summary>
        /// 判断是邮箱是否存在
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public void isNewOrder(HttpContext htContext)
        {

            if (htContext.Session["admin"] == null)
            {
                htContext.Response.Write("no");
            }
            else
            {
                string[] str = htContext.Session["admin"].ToString().Split('&');
                string id = "";
                if (str.Length == 2)
                {
                    id = htContext.Server.UrlDecode(str[1]);
                }
                if (string.IsNullOrWhiteSpace(id))
                {
                    htContext.Response.Write("no");
                }
                else
                {
                    BLL.Order.Order bll_order = new BLL.Order.Order();
                    int count = bll_order.GetRecordCount(" sellerid =" + id + " and state=0");
                    if (count > 0)
                        htContext.Response.Write("您有" + count + "笔订单，需要处理！");
                    else
                        htContext.Response.Write("no");
                }
            }
        }
        #endregion

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}